﻿using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using QuickUIT.Controls;

namespace QuickUIT.Tests
{
    [TestClass]
    public class UIMenuBarTests
    {
        private BaseState _baseState;

        [TestInitialize]
        public void TestSetup()
        {
            _baseState = new BaseState(TestUtilities.GetTestApplicationFileName(), "@Name='QuickUIT Test Application'");
            _baseState.Execute();
        }

        [TestMethod]
        public void ShouldGetSystemMenuBar()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            UIMenuBar menuBar = window.UIMenuBar(); 
            Assert.IsNotNull(menuBar);

            menuBar = window.UIMenuBar("@AutomationId='SystemMenuBar'"); 
            Assert.IsNotNull(menuBar);
        }

        [TestMethod]
        public void ShouldGetExpandCollapseState()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            UIMenuBar menuBar = window.UIMenuBar("@AutomationId='SystemMenuBar'"); 
            Assert.IsFalse(menuBar.ExpandCollapseState.HasValue);
        }

        [TestMethod]
        public void ShouldGetDockPosition()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            UIMenuBar menuBar = window.UIMenuBar("@AutomationId='SystemMenuBar'");
            Assert.IsFalse(menuBar.DockPosition.HasValue);
        }

        [TestMethod]
        public void ShouldGetCanMove()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            UIMenuBar menuBar = window.UIMenuBar("@AutomationId='SystemMenuBar'");
            Assert.IsFalse(menuBar.CanMove);
        }

        [TestMethod]
        public void ShouldGetCanResize()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            UIMenuBar menuBar = window.UIMenuBar("@AutomationId='SystemMenuBar'");
            Assert.IsFalse(menuBar.CanResize);
        }

        [TestMethod]
        public void ShouldGetCanRotate()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            UIMenuBar menuBar = window.UIMenuBar("@AutomationId='SystemMenuBar'");
            Assert.IsFalse(menuBar.CanRotate);
        }

        [TestMethod]
        public void ShouldGetAllMenuBars()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            List<UIMenuBar> menuBars = window.UIMenuBars();
            Assert.AreEqual(1, menuBars.Count);
        }

        [TestCleanup]
        public void TestTeardown()
        {
            _baseState.Cleanup();
        }
    }
}